{% extends 'base.html' %}

{% block style %}
    <style>
        img{
            width: 100%;
            height:100%;
        }
        .container {
            border: 1px solid black;
            background-color: white;
        }
        .jumbotron{
            padding: 0 0 0 0;
            background-color: white;
            margin-bottom: 0;
        }
        .container .jumbotron, .container-fluid .jumbotron {
            padding-right: 0;
            padding-left: 0;
        }
        @media (min-width: 768px) {
          .container {
            max-width: 540px;
          }
        }
        .pull-right {
            width: 100%;
        }
        .pull-right li {
            width: 33%;
            height: 100%;
            text-align: center;
            font-size: 20px;
        }
        .nav-pills > li+li{
            margin-left: 0;
        }
        .pull-right li:first-child{
            border-right: 1px solid lightgrey;
            border-bottom: 5px solid #d7736b;
        }
        .pull-right li:nth-child(2){
            border-right: 1px solid lightgrey;
            border-bottom: 5px solid #4587c0;
            border-right: 0;
        }
        .pull-right li:last-child{
            border-left: 1px solid lightgrey;
            border-bottom: 5px solid #685c89;
        }
        .titles-s {
            font-size: 24px;
            padding-top: 5px;
            font-weight: 700;
            color: #888888;
        }
        .titles-l {
            color: #8e9899;
            font-size: 18px;
        }
        .header{
            height: 85px;
            padding-bottom: 10px;
            border-bottom: 0;
        }
        @media screen and (min-width: 768px) {
          /* Remove the padding we set earlier */
          .header,
          .marketing,
          .footer {
            padding-right: 0;
            padding-left: 0;
          }
          .header {
            margin-bottom: 20px;
          }
          .jumbotron {
            border-bottom: 0;
          }
        }

        .tj_y{
            text-align: center;
            font-size: 24px;
            color: #666766;
            padding-bottom: 4px;
        }
        .common {
            text-align: center;
            padding-top: 10px;
            width: 90%;
            margin: 0 auto;
        }
        .row p:nth-child(3){
            padding-top: 0;
        }
        .row p:nth-child(11){
            font-size: 18px;
            color: #666667;
        }
        .from_main{
            width: 100%;
            margin-top: 20px;
            color: #666667;
        }
        .items_common{
            margin: 10px auto;
        }
        .reward {
            color: #666667;
            font-size: 20px ;
            font-weight: 700;
        }
    </style>
{% endblock %}

{% block content %}
    <div class="container">
      <div class="header">
          <ul class="nav nav-pills pull-right">
            <li><p class="titles-s">0</p><p class="titles-l">You Entries</p></li><!---->
            <li><p class="titles-s">{{ people_number }}</p><p class="titles-l">Totals Entries</p></li><!---->
            <li id="timer">
                <p class="titles-s" id="day-time"></p>
                <p class="titles-l" id="time-list"></p>
            </li>
          </ul>
      </div>
      <div class="tj_y">
          Join the Raptor baby white list
      </div>
      <div class="jumbotron">
          <img src="/static/images/banner.png" alt="banner.png">
      </div>
      <div class="row">
{#        <p class="common">Complete the following tasks to be entered into the Auntie Whale Whitelist Lottery! We're also hosting a $5000 Cash giveaway to ALL entries!</p>#}
{#        <p class="common">#}
{#            🎯 Score 50-100 points - Entered into round <b>1 Lotto</b>#}
{#        </p>#}
{#        <p class="common">#}
{#            🎯 Score 10-50 points - Entered into Round <b>2 Lotto</b>#}
{#        </p>#}
{##}
{#        <p class="common">#}
{#            <b>If you are not picked in Round 1 we will add your entries into round 2 for second chance! Public Round 3 will be activated if no sellout.</b>#}
{#        </p>#}
{##}
{#        <p class="common">Cash Prize Breakdown:</p>#}
{#        <p class="common">We will use our platform to randomly pick 100 entries. Every entry picked will win $50 directly sent to your wallet!</p>#}
{#        <p class="common">🏆 100 x Random Entries - $50  🏆</p>#}
{#        <p class="common">⏰  The competition will end: 15th July - 4 PM UTC ⏰</p>#}
{#        <p class="common"><b>IMPORTANT</b> - It's paramount you use a working email. Please go to your inbox and confirm our whitelist notification email.</p>#}
{#        <P class="common reward">{{ title }}</P>#}
{#        <p class="common">---------------------------------------------------------------</p>#}
{#        <p class="common">Please complete your details to begin</p>#}
          <p class="common reward">Raptor baby white list ends on July 19</p>
          <p class="common reward">Raptor baby white list competition</p>
          <p class="common reward">100  winners</p>
          <p class="common reward">0.5 min / 10 Max contribution</p>
      </div>

      <div class="from_main">
          <form class="form-inline" id="form_d" action="/index/" method="post">
              <input type="hidden" value="{% csrf_token %}">
              <div class="items_common">
                  <div class="form-group">
                    <label for="full_name" style="margin-right: 70px">Full Name:</label>
                    <input type="text" class="form-control" id="full_name" placeholder="Jane Doe" alt="请填写该字段" name="full_name">
                  </div>
                  <span style="margin-left: 60px">Reqiured</span>
              </div>
              <div class="items_common">
                  <div class="form-group">
                    <label for="email" style="margin-right: 100px">Email:</label>
                    <input type="email" class="form-control" id="email" placeholder="jane.doe@example.com" alt="请填写该字段" name="email">
                  </div>
                  <span style="margin-left: 60px" id="text">Reqiured</span>
              </div>

{#              <div class="items_common">#}
{#                  <div class="form-group">#}
{#                    <label for="username" style="margin-right: 5px">Telegram username:</label>#}
{#                    <input type="email" class="form-control" id="username" alt="请填写该字段" name="telegram_username">#}
{#                  </div>#}
{#                  <span style="margin-left: 60px">Reqiured</span>#}
{#              </div>#}
{#              <div class="items_common">#}
{#                  <div class="form-group">#}
{#                    <label for="bep" style="margin-right: 35px">Wallet Address:</label>#}
{#                    <input type="email" class="form-control" id="bep" alt="请填写该字段" name="bep_wallet_address">#}
{#                  </div>#}
{#                  <span style="margin-left: 60px">Reqiured</span>#}
{#              </div>#}
              {% if show %}
                  <div style="text-align: center; color: red; padding-top: 5px;font-size: 20px">
                      您已参加过本次活动！请等待开奖!
                  </div>
              {% endif %}
              <hr>
              <div style="margin: 0 auto; text-align: center; padding-bottom: 10px">
                  <button type="button" class="btn btn-primary btn-block" id="commit">Commit</button>
              </div>
        </form>
      </div>
      <div>
          <hr>
          <button class="btn-block btn btn-success" onclick="location.href='/s_page/'">Query winning information</button>
      </div>
      <footer class="footer">
        <p>&copy; 2021 Company, Inc.</p>
      </footer>

    </div> <!-- /container -->
{% endblock %}


{% block js %}
    <script>
        $(document).ready(function (){

            function showError(){
                let value = $(this).val()
                if (value === '' || undefined || null){
                    $(this).parent().addClass('has-error')
                    $(this).siblings(1).css('color', 'red')
                    $(this).parent().siblings('span').css('color', 'red')
                }else{
                    $(this).parent().removeClass('has-error')
                    $(this).siblings(1).css('color', '#666667')
                    $(this).parent().siblings('span').css('color', '#666667')
                }
            }

            $("#full_name").focusout(showError)
            $("#email").focusout(showError)
            {#$("#username").focusout(showError)#}
            {#$("#bep").focusout(showError)#}

            $('#commit').click(function (){

                let full_name = $("#full_name").val()
                let email = $("#email").val()
                let username = $("#username").val()
                let bep = $("#bep").val()

                if ((full_name === '' || undefined || null) ||
                    (email === '' || undefined || null) ||
                    (username === '' || undefined || null) ||
                    (bep === '' || undefined || null)
                ) {
                    let InputControl = $('.form-control')
                    InputControl.map(function (index, vale) {
                        let value = $(vale).val()
                        if (value === '' || undefined || null) {
                            $(this).parent().addClass('has-error')
                            $(this).siblings(1).css('color', 'red')
                            $(this).parent().siblings('span').css('color', 'red')
                        } else {
                            $(this).parent().removeClass('has-error')
                            $(this).siblings(1).css('color', '#666667')
                            $(this).parent().siblings('span').css('color', '#666667')
                        }
                    })
                }else{
                    var reg = /^([a-zA-Z]|[0-9])(\w|\-)+@[a-zA-Z0-9]+\.([a-zA-Z]{2,4})$/;
                    if(reg.test(email)){

                        $("#form_d").submit()
                    }else{
                        $("#text").text("wrong email").css("color", 'red')
                        return
                    }
                }
            })


            function getTime(val) {
                var d,h,m,s,timeText;
                var oP = $('#time-list');
                setInterval(function(){
                    val--;
                    d = parseInt(val /(24*3600));
                    h = parseInt(val/60/60%24);
                    m = parseInt(val/60%60);
                    s = parseInt(val%60);
                    s = s < 10 ? "0" + s : s ;
                    timeText = h +"时" + m + "分" + s + "秒";
                    oP.text(timeText)
                    $('#day-time').text(d + "天");
                },1000)
            }

            if({{ left_time }} > 0 ) {
                getTime({{ left_time }})
            } else {
                $('#day-time').text("0天");
                $('#time-list').text("00时00分00秒");
            }
        })
    </script>
{% endblock %}
